package code.hkgolden.android.service;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

import org.apache.commons.lang.CharEncoding;

import com.google.inject.Singleton;

@Singleton
public class DefaultHttpService implements HttpService {

	@Override
	public String getFromUrl(URL url) throws IOException {
		BufferedReader reader = null;
		try {
			URLConnection urlConnection = url.openConnection();
			reader = new BufferedReader(new InputStreamReader(
					urlConnection.getInputStream(), CharEncoding.UTF_8));
			return reader.readLine();
		} finally {
			if (reader != null) {
				reader.close();
			}
		}
	}

}
